package com.wdciti.sccp.iot.springvertx.protocols.tcp;

import com.wdciti.sccp.iot.common.endpoint.EndpointConfig;
import com.wdciti.sccp.iot.common.endpoint.EndpointType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author early
 */
@EqualsAndHashCode
@Data
@Configuration
public class TcpEndpointConfig implements EndpointConfig {

    private String name;

//    private String id = UUID.randomUUID().toString();

    private EndpointType endpointType;

    private String codec;

    private Integer port;

    private String host;

    private boolean enable = false;

    private Integer instance = 1;

    private Boolean isHa = false;

    private Boolean isWorker = false;

    private Map<String, Object> configJson = new HashMap<>();


    public TcpEndpointConfig() {
    }

    @Override
    public Map<String, Object> getConfigMap() {

        configJson.put("host", host);
        configJson.put("port", port);
        if (codec != null) {
            configJson.put("codec", codec);
        }
        configJson.put("instance", instance);
        configJson.put("isHa", isHa);
        configJson.put("isWorker", false);
        return configJson;
    }


}
